package com.monkey.luffer.springboot.demo.task.elastic.job.listener;

import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: dengkaibing
 * @Description:
 * @Date: 2020/11/16 17:05
 * @company 甜橙金融
 * @Version: 1.0
 */
@Slf4j
public class JobListener implements ElasticJobListener {
    //定时任务监听器实现ElasticJobListener

    /**
     * 定时任务执行前
     *
     * @param shardingContexts
     * @return
     */
    @Override
    public void beforeJobExecuted(ShardingContexts shardingContexts) {
        log.info("start job名称:{}，总分片数:{}", shardingContexts.getJobName(), shardingContexts.getShardingTotalCount());
    }

    /**
     * 定时任务执行后
     *
     * @param shardingContexts
     * @return
     */
    @Override
    public void afterJobExecuted(ShardingContexts shardingContexts) {
        log.info("end job名称:{}，总分片数:{}", shardingContexts.getJobName(), shardingContexts.getShardingTotalCount());

    }
}
